home *** CD-ROM | disk | FTP | other *** search
Text File | 1990-08-21 | 1.7 KB | 85 lines | [TEXT/MPS ] |
- // TestPtrObject.cp
- #include <Types.h>
- #include <QuickDraw.h>
- #include <Fonts.h>
- #include <SegLoad.h>
- #include <Events.h>
- #include <Windows.h>
- #include <Menus.h>
- #include <TextEdit.h>
- #include <Dialogs.h>
- #include <Memory.h>
- #include <OSUtils.h>
- #include <stdio.h>
- #include <string.h>
- #include <stddef.h>
-
- #include "PtrObject.h"
-
- // A small class that contains some data and a constructor,
- // but spends all of its time on street corners cadging
- // cigarettes instead of doing useful work.
- class TLout : public PtrObject {
- public:
- // Our constructor.
- TLout() { DoCadge(); };
- // A rude member function.
- virtual void DoCadge();
- private:
- char fArray[256];
- };
-
- void TLout::DoCadge()
- {
- strcpy(fArray,"Hey buddy, spare a cig?");
- };
-
- void InitToolbox(); // Forward declaration.
-
- void main()
- {
- // Initialize Mac Toolbox (ho hum).
- InitToolbox();
-
- // We need this much space to store the objects
- // we’re going to initialize - in this case, 16KBytes.
- const size_t kDefaultHeapSize = 0x4000;
-
- // Create a heap for PtrObjects to live in.
- OSErr heapErr = PtrObject::AllocHeap(kDefaultHeapSize);
-
- // If we got an error, quit - this isn’t a real
- // application, so we don’t need error handling, right?
- if (heapErr != noErr)
- ExitToShell();
-
- // Create an object - will go in separate heap automatically.
- TLout* aLout = new TLout;
-
- // Do that voodoo that TLouts do…
- if (aLout != nil)
- {
- aLout->DoCadge();
- // Delete our object now that we have finished with it.
- delete aLout;
- }
-
- // Dispose of the heap.
- PtrObject::DisposeHeap();
- ExitToShell();
- }
-
- void InitToolbox()
- {
- // Standard Macintosh initialization.
- InitGraf((Ptr) &qd.thePort);
- InitFonts();
- InitWindows();
- InitMenus();
- TEInit();
- InitDialogs(nil);
- InitCursor();
- MaxApplZone();
- }
-
-